package com.gf.demo.debugdemo.controller;

import com.gf.framework.common.result.R;
import com.gf.framework.web.annotation.MemoryCache;
import com.gf.framework.web.annotation.MemoryCacheClear;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author gaofei
 * @date 2023/7/31 16:22
 */
@RestController
@RequestMapping("memory")
@Api(tags = "内存缓存测试")
public class MemoryCacheController {

    private static final String KEY = "memory-test";

    @GetMapping("test")
    @MemoryCache(type = MemoryCacheController.KEY)
    public R<String> getMemory() throws InterruptedException {
        Thread.sleep(1000);
        return R.success("成功");
    }

    @GetMapping("clear")
    @MemoryCacheClear(type = MemoryCacheController.KEY)
    public R<Boolean> clear() {
        return R.success();
    }
}
